<template>
    <sub-box>
        <breadcrumb :title="'申请详情'"></breadcrumb>
        <div v-loading="loading" class="mt20">
            <div class="box-th white-block mt20" v-if="detail">
                <div class="form-common clearfix">
                    <div class="form-item">
                        <div class="form-item-label">自建系统名称</div>
                        <div class="form-item-content">{{detail.sysName}}</div>
                    </div>
                    <div class="form-item">
                        <div class="form-item-label">自建系统代码</div>
                        <div class="form-item-content">{{detail.sysCode}}</div>
                    </div>
                    <div class="form-item">
                        <div class="form-item-label">自建系统描述</div>
                        <div class="form-item-content">{{detail.sysDesc}}</div>
                    </div>
                </div>
            </div>
            <div class="box-th white-block mt20" v-if="detail">
                <table-example :data="detail.ipChanges" :tableColumn="header" :slotColumns="slotColumns" class="mt20">
                    <template slot="type" slot-scope="scope">
                        <span v-if="scope.row.type==0">新增</span>
                        <span v-if="scope.row.type==1">修改</span>
                        <span v-if="scope.row.type==2">删除</span>
                    </template>
                    <template slot="oldResName" slot-scope="scope">
                        <p v-for="(item,value) in scope.row.oldResName" :key="value">{{item}}</p>
                    </template>
                    <template slot="newResName" slot-scope="scope">
                        <p v-for="(item,value) in scope.row.newResName" :key="value">{{item}}</p>
                    </template>
                    <template slot="oldIP" slot-scope="scope">
                        <template v-if="scope.row.oldIP">
                            <p v-for="(ip, index) in scope.row.oldIP.split(',')" :key="index">
                                {{ip}}
                            </p>
                        </template>
                    </template>
                    <template slot="newIP" slot-scope="scope">
                        <template v-if="scope.row.newIP">
                            <p v-for="(ip, index) in scope.row.newIP.split(',')" :key="index">
                                {{ip}}
                            </p>
                        </template>
                    </template>
                </table-example>
            </div>
        </div>
    </sub-box>
</template>

<script>
    import subBox from '../../components/layout/layout-sub'
    import breadcrumb from '../../components/breadcrumb'
    import tableExample from '../../components/table'
    import audit from '../../components/audit'

    export default {
        data() {
            return {
                tableData: [],
                header: [
                    {
                        prop: 'type',
                        label: '类型',
                        minWidth: '10%',
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'oldIp',
                        label: '原IP地址',
                        minWidth: '20%',
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'oldResName',
                        label: '原绑定服务',
                        minWidth: '20%',
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'newIp',
                        label: '新IP地址',
                        minWidth: '20%',
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'newResName',
                        label: '新绑定服务',
                        minWidth: '20%',
                        align: 'center',
                        headerAlign: 'center'
                    }

                ],
                id: '',
                applyNo: '',
                slotColumns: ['type', 'oldResName', 'newResName', 'newIP', 'oldIP'],
                loading: false,
                detail: null
            }
        },
        mounted() {
            if (this.$route.query.id) this.id = this.$route.query.id
            this.getDetail()
        },
        methods: {
            getDetail() {
                this.loading = true
                this.$http.get('/rdIpImpleOrder/ipImplementationOrderInfo', {
                    orderId: this.id
                }).then(result => {
                    this.loading = false
                    if (result.success) {
                        this.detail = result.data
                    }
                }).catch(() => {
                    this.loading = false
                })
            }
        },
        components: {
            subBox,
            breadcrumb,
            tableExample,
            audit
        }
    }
</script>
<style scoped lang="less">
    .box {
        padding: 30px 20%;

        .timeline-card {
            display: inline-flex;
            align-items: center;
            width: 100%;

            > * {
                flex: auto;
            }

            .el-card {
                width: 80%;
            }

            .timeline-btn {
                width: 20%;

                button {
                    border-radius: 20px;
                }
            }
        }

        .time {
            font-size: 18px;
            margin-bottom: 3px;
        }

        .name {
            span {
                float: right;
            }
        }

        .remark {
            color: #999;

            &.error {
                color: #E00000;
            }
        }

    }
</style>
